package com.btrh.exception_handler;

import com.btrh.util.R;
import exception.UserAlreadyDeleteException;
import exception.UserNotFoundExecption;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author zyy
 * @date 2020/9/8 9:44
 * @description
 */
@RestControllerAdvice
public class GlobeExceptionHandler {

    /**
     * 用户不存在异常
     * @param ex
     * @return
     */
    @ExceptionHandler(UserNotFoundExecption.class)
    public R UserNotFoundExecption(UserNotFoundExecption ex){
        return R.failed(ex.getMessage());
    }

    /**
     * 用户已被注销异常
     * @param ex
     * @return
     */
    @ExceptionHandler(UserAlreadyDeleteException.class)
    public R UserAlreadyDeleteException(UserAlreadyDeleteException ex){
        return R.failed(ex.getMessage());
    }
}
